package host.springboot.framework.core.model;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * Pair
 *
 * @author JiYinchuan
 * @since 1.0.0
 */
@Data
@AllArgsConstructor
public class Pair<L, R> {

    /**
     * Left object
     */
    public final L left;

    /**
     * Right object
     */
    public final R right;

    /**
     * <p>Creates an immutable pair of two objects inferring the generic types.</p>
     *
     * <p>This factory allows the pair to be created using inference to
     * obtain the generic types.</p>
     *
     * @param <L>   the left element type
     * @param <R>   the right element type
     * @param left  the left element, may be null
     * @param right the right element, may be null
     * @return a pair formed from the two parameters, not null
     */
    public static <L, R> Pair<L, R> of(final L left, final R right) {
        return new Pair<>(left, right);
    }
}
